package magicboard.classifier.feature.features
{
	import magicboard.geometry.Vector;
	import magicboard.model.InkStroke;
	
	/**
	 * Extract number of segments.
	 */
	public class EndCosFeature extends FeatureExtractor{
		
		public static var ID:String = "endcos";
		 
		// --------------------------------------------------------------------------------------------
		public function EndCosFeature(){
			
			super(ID);
		}
		
		// --------------------------------------------------------------------------------------------
		/**
		 * Calculate end point alpha
		 */
		override public function extract(stroke:InkStroke):Number{
			
			var length:int = stroke.simplifiedPoints.length;
			if(stroke.simplifiedPoints.length < 2)
				return 0;
				
			var v:Vector = Vector.points2Vector(stroke.simplifiedPoints[length-1], stroke.simplifiedPoints[length-2]);
			return 0.5 * (v.cos + 1);
		}
		
		// --------------------------------------------------------------------------------------------
		// Private members
	}
}